Worksheet 1, Math 151

ANALYSIS OF ALGEBRAIC & TRIGONOMETRIC FUNCTIONS

Introduction

Goals: In this worksheet we will define functions and analyze their domains, ranges and zeros using Mathematica. We will also consider step functions, composite functions, and horizontal and vertical shifts of functions.

First, read "intro.nb". As you read, execute each of the Mathematica commands. Observe and learn. (Later, you may wish to use this introduction as a reference guide, since it quickly demonstrates the essentials of Mathematica.)

Next, work through the following problems in a Mathematica notebook.  Save often!  When you are done, revise your work so that it is easy for the TA to find and understand your solutions.

Examples

To define the function f(x)=(((x^3)-7(x^2)-x+7)/50) in Mathematica, we enter:

f[x_]:=(((x^3)-7(x^2)-x+7)/50)

Note that since f is a polynomial, we know that Dom(f) = (-∞, ∞), and because f is of odd order it follows that Ran(f)= (-∞, ∞). Now we may plot f over the interval [-20, 20] with the following command:

Plot[f[x],{x,-20,20}, PlotStyle -> Blue]

To locate the zeros of f we factor the polynomial expression f(x):

Factor[f[x]]

Evidently, f has three zeros: x=-1,1,7. Alternatively, we can find these zeros by writing a Mathematica command to solve the equation f(x)=0 for x.

s=Reduce[f[x]==0,x]

Note: In the previous command, the sign "==" means "equal". In contrast, sign "=" means give the value of rhs to lhs.

In order to refer to the first element in the list of solutions we may enter s[[1]].

s[[1]]

As you might expect, the third solution is denoted by s[[3]] in Mathematica.

s[[3]]

We may sketch a graph of f over a smaller interval to show detailed behavior of the function.

Plot[f[x],{x,-4,8},PlotStyle -> {Orange,Thick} ]

Now let's consider the function g(x)=(x^4)-(Sqrt[1+x]). We begin by defining g in Mathematica.

g[x_]:=x^4-Sqrt[1+x]

Note that Dom(g)=[-1,∞). If we try plotting g over the interval [-1,10] we obtain the following graph:

Plot[g[x],{x,-1,10}, PlotStyle -> Blue]

It appears that the zeros of g - if there is any - occur in the interval (-1,(5/2)) so it makes sense to redraw the graph over a shorter interval. Doing this will help us to estimate the locations of the zeros.

Plot[g[x],{x,-1,5/2},PlotRange -> {-5,10}, PlotStyle -> Blue]

Observe that the second interval of values in the above plot command: PlotRange -> {-5,10} specifies the range of values that appear along the y axis.

It is now evident that g has one zero in the interval (-1, -(1/2)) and one in the interval (1, (3/2)). We will attempt to find these values using a Reduce command as above:

Reduce[g[x]==0,x]

This is a very complicated looking expression which involves the root of an eighth degree polynomial. In such a case it is appropriate to utilize the N[Reduce[]] command to approximate each of the roots.

N[Reduce[g[x]==0,x]]

Note: Based on the graph above, we can only see two zeros of g(x). However, according to the last result, there are four zeros of g(x). This is because two of the four solutions are complex. So by looking at the graph, you can only see the two real ones.

Finally, to determine the range of g, we observe from our graph that since the curve falls below "y=-1", [-1, ∞) is contained in Ran(g). We will learn how to exactly find the minima and maxima of functions in Chapter 3. For now, we can estimate the minimum value of g(x) by redrawing the graph of g over the short interval [0.45, 0.60].

Plot[g[x],{x,0.45,0.6}, PlotStyle -> Blue]

Position the mouse arrow inside the coordinate plane of this plot and right click the mouse, then select "Get Coordinates". Now move the mouse arrow to the minimum point. The coordinates of the point will show aside your mouse pointer. The y-coordinate of this point approximates the minimum value of g.

The actual minimum value occurs when g'(x)=0, where g'(x) is the first derivative of g(x). You don't really have to worry about this part now (we will talk about it in Chapter 3 in much more detail).

Simplify[D[g[x],x]==0]

So for the minimum value of g(x), x is the root of the equation: 8(x^3)=(1/(Sqrt[1+x])), which is actually the same as 64(x^6)+64(x^7)=1.

x0=x/.FindRoot[64(x^6)+64(x^7)==1,{x,0.01}]

The command "FindRoot" is used to find the root of equations with the option "{x, 0.01}" telling Mathematica to locate this root near the point x=0.01. The command "/." replaces x by the value of "FindRoot[64(x^6)+64(x^7)==1,{x,0.01}]", which is then assigned to "x0".

The minimum value gMin is given by:

gMin=g[x0]

Thus, Ran(g)=[gMin,∞).

We now define the composite function h=f∘g  in Mathematica with the following command:

h[x_]:=f[g[x]]
h[x]

If we would like to expand the above expression into a sum of simpler terms we may enter:

Expand[%]

Note that the symbol "%" stands for "the last output".
Thus, the command: "Expand[%]" is equivalent to "Expand[h[x]]".

Plot[h[x],{x,-1,2},PlotRange -> {-2,5}, PlotStyle -> {Blue, Thick}]

We may also use Mathematica to study horizontal and vertical shifts of a function.
Let t(x)=sin(π x)+x.
We will utilize the sequence command, "Table", to plot the set
                       t(x)+k          for           k=0,1,2,3,4.
We first define the set tSet1:

t[x_]:=Sin[Pi*x]+x
tSet1:=Table[t[x]+k,{k,0,4}]
Plot[tSet1,{x,-6,6},PlotStyle -> Thick]

Question: Which graph represents t(x)+4?

Note that when plotting a set of expressions, we must specify the domain of the independent variable x by entering "{x,a,b}" in the Plot command.

tSet2:=Table[t[x+k],{k,0,4}]
Plot[tSet2,{x,-6,6},PlotStyle -> Thick]

Question:  Which graph represents  t( x + 4 ) ?

Finally, we consider a set tSet3, with elements of the form  t ( c x )  for various values of  c.

tSet3:=Table[t[c*x],{c,-3,3}]
Plot[tSet3,{x,-10,10},Frame -> True, PlotStyle -> Thick]

The unit step function is denoted by  UnitStep  in Mathematica. Thus,
UnitStep(x)=(Piecewise[{{1, x>0}, {0, x<0}}])

For brevity, we may call this function by the name  u .

u[x_]:=UnitStep[x]

Let's check our definition by asking  Mathematica to plot  u ( x )  over the interval  [ -10 ,  10 ] .

Plot[u[x],{x,-10,10},PlotRange -> {-1,2},PlotStyle -> {Red, Thick} ]

Of course, the graph of y  =  u ( x-2) should shift the graph of  y = u ( x )  two units to the right. We enter this now.

Plot[u[x-2],{x,-10,10},PlotRange -> {-1,2},PlotStyle -> {Thick,Magenta}]

Exercises

Exercise 1

For the function  h = f o g defined in the text above, determine all of the zeros of  h  in the interval [ -1 , 2 ]  to ten significant digits. To set the digit significance, use the command N[expr, n] where "expr" is your expression and "n" is the number of digits.

Exercise 2

( a )  Define the function j = g o f  in Mathematica, where f and g are the functions described in the discussion above.  Then display the formula for  j ( x ) .

( b )  Plot the graph of   y = j( x )   for  -6<x<9. What features are noteworthy about this graph?

( c )  Observe that j ( x ) is not defined for all real  x  due to the cubic polynomial term under the radical sign in its definition. Use the N[Reduce[ ]] command to determine the one real zero of this polynomial. Then indicate the domain of the function j .

Exercise 3

Graph the function  t ( x ) =(x^4)+(cx^2)+x  for several values of  c over the interval [ -2 , 2 ] .      
How does the graph change as c changes?  Hint: First define the function t in Mathematica and then define a sequence of functions with the command tSet = Table[t[x],{c,-4,8}].

Exercise 4

In each case, determine a non piecewise definition for the function which will yield the graph displayed below, then check your result by plotting your function. 
Your solutions should always involve products of (shifts of) the unit step function with (shifts of) the squaring function, or sums and differences of the constant function with shifts of the unit step function.

(a)

(b)

(c)

(d)

(e)

(f)

(g)

Exercise 5

We will study the behavior of the function v ( x )  = x sin((1/x)) near x=0 in this problem. 
The expression sine of x is denoted in Mathematica syntax as Sin [x] . So we may define the function v by:

v[x_] := x*Sin[1/x]

(a) Now graph of the function v  near the origin may be obtained by executing the following plot command:

Plot[v[x],{x,-1/(2*Pi),1/(2*Pi)},PlotStyle -> {Thick, Magenta}]

(b) Indicate all of the x-intercepts for v  in the interval  [-(1/(2π)) , (1/(2π))].

(c) What value does v  seem to approach as x approaches 0?  Explain your answer both geometrically and algebraically.

Exercise 6

The figure below shows two unit circles. The first is centered at the origin and the second at the point T=( 2 , 0 ).
Note that:   ( i ) segment R Q is tangent to the second circle,
                 ( ii ) P is the point where segment R Q intersects the first circle,  
                 ( iii ) the point R has coordinates (-1,0).

Carry out the following steps to find the exact coordinates of the points P and Q.

( a )  Observe that △ R Q T is right.
        Use the converse to the Pythagorean Theorem to find the length of side Q R.

( b )  Find the tangent of angle θ.

( c )  Write the equation of line R Q. (Hint: tan θ=slope of R Q.)

( d )  Find the coordinates of point P=(P x, P y).
         (Hint: Solve simultaneously the equations which describe line R Q and the first unit circle.)

( e )  Find the coordinates of point Q=(Q x, Q y). 
        (Hint: Compare cos θ and sin θ as described in the right triangles △ R Q T and △ R S Q to determine Q x and Q y respectively.)

( f )  To check your answers, replace the question marks below with the actual values for P x, P y, Q x, and Q y. Then execute this sequence.
        You should see displayed a dashed path from R to P and a solid path from R to Q.

Exercise 7

That's all fine when there's clearly something wrong with the plot. Unfortunately, it's not hard to come up with a very misleading function, that seems to be okay, but ...

f[x_]:=((((1/2)))^(((((500*x))^2))))+Sin[x]

Plot[f[x],{x,-10,10}]

2. a.

From the plot, what does the limit of f at x=0 appear to be?

2. b.

Mathematica can find the limit of f at x=0, as follows :

Limit[f[x],x-> 0]

(If this went as expected, this does not agree with your answer to 2. a.)

2. c.

Modify the above plot, changing the visible domain so that you can get a better look at the function near, until you have obtained a plot that explains the apparent paradox.

Exercise 8

Demonstrate the Squeeze Theorem by making a single plot of the graphs of these three functions: f(x)=(x^2), g (x) = (x^2)cos((1/x)), and h(x)=-(x^2).
The plot should be over the domain (-10, 10).
Then, make a second plot that magnifies a portion of the graph near the origin, to better see how the three functions behave when x is near 0.
Make a third plot that focuses on an even smaller region near the origin.